package c.f.d.a.a.b.g;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import c.f.a.a.a.a;
import java.util.List;

public class c {
    public static final String a = "c";

    public static boolean a(String str) {
        Context context = a.a;
        if (context == null) {
            return false;
        }
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            try {
                List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(0);
                if (installedApplications != null) {
                    for (ApplicationInfo applicationInfo : installedApplications) {
                        if (applicationInfo.packageName.equals(str)) {
                            return true;
                        }
                    }
                }
            } catch (Exception unused) {
                a.k(a, "exception");
            } catch (Throwable unused2) {
                a.k(a, "throwable");
            }
        }
        return false;
    }

    public static String b(String str) {
        String str2;
        StringBuilder g;
        Context context = a.a;
        String str3 = "";
        if (context == null) {
            return str3;
        }
        try {
            return context.getPackageManager().getPackageInfo(str, 0).versionName;
        } catch (NameNotFoundException e) {
            str2 = a;
            g = c.b.a.a.a.g("getVersion NameNotFoundException : ");
            g.append(e.getMessage());
            a.k(str2, g.toString());
            return str3;
        } catch (Exception e2) {
            str2 = a;
            g = c.b.a.a.a.g("getVersion: ");
            g.append(e2.getMessage());
            a.k(str2, g.toString());
            return str3;
        } catch (Throwable unused) {
            a.k(a, "throwable");
            return str3;
        }
    }
}
